package com.cloud.example.business.async.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.cloud.async.flow.util.timer.SystemClock;
import com.cloud.example.business.async.entity.Car;
import com.cloud.example.business.async.entity.Person;
import com.cloud.example.business.async.service.CalledAsyncService;
import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;

/**
 * 被调用测试
 *
 * @author chengrui
 */
@Service
public class CalledAsyncServiceImpl implements CalledAsyncService {
    @Override
    public String calledAsync(String name) {
        Person person = new Person();
        person.setAge(22);
        person.setCarName("吉利帝豪");
        person.setName("chengr");

        Car car = new Car();
        car.setCarName("吉利帝豪" + SystemClock.now());
        car.setColor("blue");
        car.setUseAge(2);

        person.setCar(car);

        try {
            TimeUnit.SECONDS.sleep(3);
        } catch (Exception e) {

        }
        return JSONObject.toJSONString(person);
    }
}
